package com.zhanghe.study.design_pattern.mediator_pattern;

/**
 * @author zh
 * @date 2022/10/10 12:09
 */
public class ConcreteMediator implements Mediator {
    private ConcreteColleagueA concreteColleagueA;

    private ConcreteColleagueB concreteColleagueB;

    public void setConcreteColleagueA(ConcreteColleagueA concreteColleagueA) {
        this.concreteColleagueA = concreteColleagueA;
    }

    public void setConcreteColleagueB(ConcreteColleagueB concreteColleagueB) {
        this.concreteColleagueB = concreteColleagueB;
    }

    @Override
    public void changed(Colleague colleague) {
        // 协调两个同事之间的交互
        if(colleague == concreteColleagueA){
            System.out.println("concreteColleagueA 完成工作了");
        } else if(colleague == concreteColleagueB){
            System.out.println("concreteColleagueB 完成工作了");
        }
    }
}
